package com.example.homemodule.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.homemodule.model.bean.ReBuyEntity;
import com.example.homemodule.R;

import java.util.List;

/**
 * Created by SHICHENG
 * <p>
 * Time on 2022/01/04
 */
public class BuyDrugAdapter extends BaseQuickAdapter<ReBuyEntity.DataBean, BaseViewHolder> {
    public BuyDrugAdapter(@Nullable List<ReBuyEntity.DataBean> data) {
        super(R.layout.item_buydrug_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ReBuyEntity.DataBean item) {
        String imgStr = "";
        String txt1 = "";
        String txt2 = "";
        helper.setVisible(R.id.item_rebuy_txt1,false);
        helper.setVisible(R.id.item_rebuy_txt2,false);
        helper.setVisible(R.id.item_rebuy_drug,false);
        switch (item.getType()){
            case "1":
                imgStr = item.getDoctorUrl();
                txt1 = "诊断："+item.getDiagnose();
                txt2 = "用药："+item.getCommodityName();
                helper.setText(R.id.item_rebuy_txt1,txt1);
                helper.setText(R.id.item_rebuy_txt2,txt2);
                helper.setVisible(R.id.item_rebuy_txt1,true);
                helper.setVisible(R.id.item_rebuy_txt2,true);
                break;
            case "2":
                imgStr = item.getDrugUrl();
                helper.setText(R.id.item_rebuy_drug,item.getCommodityName());
                helper.setVisible(R.id.item_rebuy_drug,true);
                break;
        }

        Glide.with(mContext).load(imgStr).into((ImageView) helper.getView(R.id.item_rebuy_img));

    }
}
